{% extends "base/page.html" %}
{% load pgfilters %}

{% block extrahead %}
{% if major_version is not None and minor_version is not None %}
  <base href="/docs/{{ major_version }}/" />
{% endif %}
{% endblock extrahead %}

{%block title%}Release Notes{%endblock%}

{% block contents %}
{% regroup release_notes by major as release_note_groups %}

<div id="release-notes" class="row">
  {% if major_version is not None and minor_version is not None %}
    <div class="col-md-10">
      <section>
        <h1>Release Notes <i class="far fa-file-alt"></i></h1>
        <h2>
          {% if major_version == '0' %}Postgres95{% else %}PostgreSQL{% endif %}
          {{ major_version }}.{{ release_note.minor|release_notes_pg_minor_version:major_version }}
        </h2>
      </section>
      <div id="docContent">
        {{ release_note.content|safe }}
      </div>
      <div class="row">
        <div class="col-md-3">
          {% if release_note.previous is not None %}
            <a href="/docs/release/{{ major_version }}.{{ release_note.previous|release_notes_pg_minor_version:major_version }}/">
              Previous
            </a>
          {% endif %}
        </div>
        <div class="col-md-6 text-center">
          <p>
            <a href="/docs/release/">
              Return to the Release Notes Archive
            </a>
          </p>
        </div>
        <div class="col-md-3 text-right">
          {% if release_note.next is not None %}
            <a href="/docs/release/{{ major_version }}.{{ release_note.next|release_notes_pg_minor_version:major_version }}/">
              Next
            </a>
          {% endif %}
        </div>
      </div>
    </div>
    <div class="col-md-2 version-list">
      <section>
        <h2>Versions</h2>
      </section>
      <ul>
        {% for r in release_notes %}
          <li>
            {% if r.minor == release_note.minor %}
              <strong>
                {{ major_version }}.{{ r.minor|release_notes_pg_minor_version:major_version }}
              </strong>
            {% else %}
              <a href="/docs/release/{{ major_version }}.{{ r.minor|release_notes_pg_minor_version:major_version }}/">
                {{ major_version }}.{{ r.minor|release_notes_pg_minor_version:major_version }}
              </a>
            {% endif %}
          </li>
        {% endfor %}
      </ul>
    </div>
  {% else %}
    <div class="col-md-9">
      <section>
        <h1>Release Notes <i class="far fa-file-alt"></i></h1>
      </section>
      <p>Below is the complete archive of release notes for every version of PostgreSQL.</p>
      <ul class="release-notes-list fa-ul">
        {% for release_note_group in release_note_groups %}
          {% with major_version=release_note_group.grouper %}
            <li>
              <a class="collapsed" href="#release{{ major_version|cut:"." }}" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="release{{ major_version|cut:"." }}">
                <span class="fa-li right"><i class="fas fa-angle-right"></i></span>
                <span class="fa-li down"><i class="fas fa-angle-down"></i></span>
                {% if major_version == 0 %}Postgres95{% else %}PostgreSQL {{ major_version }}{% endif %}
              </a>
              <ul class="collapse release-notes-list" id="release{{ major_version|cut:"." }}">
                {% for release_note in release_note_group.list %}
                  <li>
                    <a href="/docs/release/{{ major_version }}.{{ release_note.minor|release_notes_pg_minor_version:major_version }}/">
                      {{ major_version }}.{{ release_note.minor|release_notes_pg_minor_version:major_version }}
                    </a>
                  </li>
                {% endfor %}
              </ul>
            </li>
          {% endwith %}
        {% endfor %}
      </ul>
    </div>
  {% endif %}
</div>

{% endblock %}
